Skip to main content
Version: 1.0.0

schema

Schema

Schema is used to describe a field present in data. Schema definition is a simple key value pair.

Following properties are available on the schema object both for measure and dimension.

PropertyDescriptionRequiredExample
nameName of the fieldtrue"sales"
typeType of field (dimension or measure)false (defaults to "dimenson""dimension"
subtypeSubtype of fieldfalse"Temporal"
defAggFnDefault aggregation function for measuresfalse"sum"
formatFormat specification for dates/numbersfalse"MM/DD/YYYY"
displayNameCustom name for field displayfalse"Total Sales"

1. name: Name of the variable.

  • The field must exist in the data. It is the only mandatory property in schema.

2. type: type of the variable.

  • The options are 'measure' and 'dimension'. Default is 'dimension'.

For a dimension the following fields are available on schema object

  • subtype: specifies what kind of dimension it is.
    • Currently the options are 'categorical', 'temporal' and 'binned'.
    • Default is 'categorical'
  • format: This filed has a multi usage as described below
    • If subtype temporal and the value type of data of this field is in timestamp then it can have function which will be used to get the value from datamodel in that format.
    • If subtype temporal and the value type of data of this field is in string format , then this should have the format of Date data which will be used to parse the date.
    • If subtype is categorical , this should have a function to format the data in this field.
  • binSize: This should be of type Number to provide bin size for binned field.

For a measure the following fields are available on schema object

  • subtype: The subtype for measure is always is 'continuous'
  • defAggFn: function to be used when field is aggregated.
  • format: a function which returns the formatted value of a variable. This is only for output purpose.
NameMiles_per_GallonCylindersDisplacementHorsepowerWeight_in_lbsAccelerationYearOrigin
chevrolet chevelle malibu1883071303504121970USA
ford fiesta36.149866180014.41978USA
bmw 320i21.54121110260012.81977Europe

The schema would be something like

[
{
"name": "Name",
"type": "dimension"
},
{
"name": "Maker",
"type": "dimension"
},
{
"name": "Miles_per_Gallon",
"type": "measure",
"defAggFn": DataModel.AggregationFunctions.MAX
},
{
"name": "Displacement",
"type": "measure",
"defAggFn": DataModel.AggregationFunctions.MAX
},
{
"name": "Horsepower",
"type": "measure",
"defAggFn": DataModel.AggregationFunctions.AVG
},
{
"name": "Weight_in_lbs",
"type": "measure",
"defAggFn": DataModel.AggregationFunctions.MIN,
"format": val => `Total weight in pounds ${val}`
},
{
"name": "Acceleration",
"type": "measure",
"defAggFn": DataModel.AggregationFunctions.AVG,
"displayName": "Acc"
},
{
"name": "Origin",
"type": "dimension"
},
{
"name": "Cylinders",
"type": "dimension"
},
{
"name": "Year",
"type": "dimension",
"subtype": "temporal",
"format": "%Y-%m-%d"
}
]